package Day07;

import java.util.Scanner;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-09-18
 * Time: 21:12
 * To BE A Better Person-2020-3-2
 */
public class TeestDemo1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int fib1=0;
        int fib2=1;
        int fib3=0;
        while(fib3 < num){
            fib3=fib1+fib2;
            fib1=fib2;
            fib2=fib3;
        }
        System.out.println(Math.min(fib3 - num, num-fib1)) ;
    }
}
